package com.cby.library.data.model

import com.google.gson.annotations.SerializedName
import android.text.TextUtils
import java.io.Serializable

class GameInfoBean : Serializable {
    @SerializedName("game_id")
    var gameId: String? = null

    @SerializedName("title")
    var title: String? = null

    @SerializedName("class_name")
    var className: String? = null

    @SerializedName("rotate")
    var rotate: String? = null

    @SerializedName("size")
    var size: String? = null

    @SerializedName("date")
    var date: String? = null

    @SerializedName("link")
    var link: String? = null

    @SerializedName("icon")
    var icon: String? = null

    @SerializedName("summary")
    var summary: String? = null

    @SerializedName("score")
    var score = 0.0

    @SerializedName("gift")
    var gift = 0

    @SerializedName("game_type")
    var gameType: String? = null

    @SerializedName("hits")
    var hits = 0

    @SerializedName("tags")
    var tags: List<Tag>? = null

    @SerializedName("desc")
    var desc: String? = null

    @SerializedName("pics")
    var pictures: List<String>? = null

    @SerializedName("thumbnail")
    var thumbnail: String? = null

    @SerializedName("material")
    var material: Material? = null

    @SerializedName("rank")
    var ranking: Ranking? = null

    @SerializedName("imgs")
    var images: List<String>? = null

    @SerializedName("origin")
    var origin = 0

    @SerializedName("recommend")
    var recommend = 0

    @SerializedName("share_count")
    var shareCount = 0
    var playCount = 1
    var timeStamp: String? = null

    @SerializedName("access_type")
    var accessType: String? = null

    @SerializedName("open_server")
    var openServer = 0

    /**
     * 预约的数量
     */
    @SerializedName("apply_count")
    var applyCount = 0

    /**
     * 发布日期
     */
    @SerializedName("publish_date")
    var publishDate: String? = null

    /**
     * 是否已预约 1已预约 0未预约
     */
    @SerializedName("applied")
    var applied = 0

    @SerializedName("banner")
    var banner: String? = null

    /**
     * 用于游戏搜索的高亮展示
     */
    var highlightText: String? = null

    /**
     * 图标标签
     * [
     * "首发",       // 名称
     * "#608dff",   // 背景色
     * "#2153d5"    // 描边色
     * ],
     */
    @SerializedName("icon_label")
    var iconLabel: List<String>? = null

    /**
     * 2.0.3版本添加，用于区分是否是预约游戏
     */
    @SerializedName("type")
    var type: String? = null

    /**
     * 是否试玩：1是0否
     */
    @SerializedName("play")
    var play = 0

    /**
     * playUrl: 游戏试玩链接地址 （仅详情接口有）
     */
    @SerializedName("playurl")
    var playUrl: String? = null

    /**
     * test: 是否结束测试  1结束,0未结束
     */
    @SerializedName("test")
    var test: String? = null

    /**
     * play_count: 试玩人数
     */
    @SerializedName("play_count")
    var demoPlayCount = 0

    @SerializedName("main_type")
    var mainType: String? = null

    @SerializedName("action")
    var action: String? = null

    /**
     * 是否有视频素材
     */
    fun hasVideo(): Boolean {
        return material != null && !TextUtils.isEmpty(material!!.video)
    }

    /**
     * 是否需要显示icon标签
     *
     * @return
     */
    fun hasIconLabel(): Boolean {
        return iconLabel != null && iconLabel!!.size >= 3
    }

    class Tag {
        @SerializedName("id")
        var id: String? = null

        @SerializedName("title")
        var title: String? = null
    }

    class Material {
        @SerializedName("img")
        var img: String? = null

        @SerializedName("gif")
        var gif: String? = null

        @SerializedName("video")
        var video: String? = null
    }

    class Ranking {
        @SerializedName("new")
        var newRanking = 0

        @SerializedName("score")
        var scoreRanking = 0

        @SerializedName("web")
        var webRanking = 0

        @SerializedName("mini")
        var miniRanking = 0
    }

    override fun toString(): String {
        return "GameInfoEntity{" +
                "gameId='" + gameId + '\'' +
                ", title='" + title + '\'' +
                ", className='" + className + '\'' +
                ", rotate='" + rotate + '\'' +
                ", size='" + size + '\'' +
                ", date='" + date + '\'' +
                ", link='" + link + '\'' +
                ", icon='" + icon + '\'' +
                ", summary='" + summary + '\'' +
                ", score=" + score +
                ", gift=" + gift +
                ", gameType='" + gameType + '\'' +
                ", hits=" + hits +
                ", tags=" + tags +
                ", desc='" + desc + '\'' +
                ", pictures=" + pictures +
                ", thumbnail='" + thumbnail + '\'' +
                ", material=" + material +
                ", ranking=" + ranking +
                ", images=" + images +
                ", origin=" + origin +
                ", recommend=" + recommend +
                ", shareCount=" + shareCount +
                ", playCount=" + playCount +
                ", timeStamp='" + timeStamp + '\'' +
                ", accessType='" + accessType + '\'' +
                ", openServer=" + openServer +
                ", applyCount=" + applyCount +
                ", publishDate='" + publishDate + '\'' +
                ", applied=" + applied +
                ", banner='" + banner + '\'' +
                ", highlightText='" + highlightText + '\'' +
                ", iconLabel=" + iconLabel +
                ", type='" + type + '\'' +
                ", play=" + play +
                ", playUrl='" + playUrl + '\'' +
                ", test='" + test + '\'' +
                ", demoPlayCount=" + demoPlayCount +
                '}' + super.toString()
    }

    companion object {
        /**
         * 试玩的状态
         */
        const val GAME_DEMO_STATUS = 1
    }
}